<template>
  <view class="template-preferred tn-safe-area-inset-bottom">
		<!-- 顶部自定义导航 -->
		<tn-nav-bar fixed alpha customBack>
			<view slot="back" class='tn-custom-nav-bar__back'
						@click="goBack">
				<text class='icon tn-icon-left'></text>
				<text class='icon tn-icon-home-capsule-fill'></text>
			</view>
		</tn-nav-bar>

    <view class="tn-flex tn-message-fixed" :style="{paddingTop: vuex_custom_bar_height + 'px'}">
    	<view class="tn-flex-1 tn-padding-sm tn-margin-xs tn-radius">
    	  <view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center" @click="handleMessageNotice(1)">
    	    <view class="icon1__item--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur tn-bg-blue tn-color-white">
						<view class="tn-icon-notice-fill" >
						</view>
    	    </view>
    	    <view class="tn-color-black tn-text-center">
    	      <text class="tn-text-ellipsis">通知</text>
    	    </view>
    	  </view>
    	</view>
      <view class="tn-flex-1 tn-padding-sm tn-margin-xs tn-radius">
        <view class="tn-flex tn-flex-direction-column tn-flex-row-center tn-flex-col-center" @click="handleMessageNotice(2)">
          <view class="icon1__item--icon tn-flex tn-flex-row-center tn-flex-col-center tn-shadow-blur tn-bg-orange tn-color-white">
            <view class="tn-icon-topics-fill">
            </view>
          </view>
          <view class="tn-color-black tn-text-center">
            <text class="tn-text-ellipsis">公告</text>
          </view>
        </view>
      </view>

    </view>



		<view class="">
			<block v-for="(item, index) in messageList" :key="index">
				<view class="article-shadow tn-margin">
					<view class="tn-flex">
						<view class="image-pic tn-margin-sm" :style="'background-image:url(' + item.avatar + ')'">
							<view class="image-article">
							</view>
						</view>
						<view class="tn-margin-sm tn-padding-top-xs" style="width: 100%;">
							<view class="tn-text-lg tn-text-bold clamp-text-1 tn-text-justify">
								{{ item.title }}
							</view>
							<view class="tn-padding-top-xs tn-text-df tn-color-gray clamp-text-2 tn-text-justify " style="min-height: 105rpx;" v-html="item.content">
<!--								<text class="tn-text-df tn-color-gray clamp-text-2 tn-text-justify" >-->
<!--									{{ item.content }}-->
<!--								</text>-->
							</view>
						</view>
					</view>
				</view>
			</block>
		</view>

    <view class='tn-tabbar-height'></view>

  </view>
</template>

<script>
	import {
		getMessageNotice,
	} from '@/api/im.js'
  import template_page_mixin from '@/libs/mixin/template_page_mixin.js'
	import UniLoadMore from "../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.vue";
	import TnBadge from "../../tuniao-ui/components/tn-badge/tn-badge.vue";
	import {parseTime} from "../../utils/ruoyi";
	export default {
    name: 'TemplateMessage',
		components: {TnBadge, UniLoadMore},
    mixins: [template_page_mixin],
		data() {
			return {
				contentText: {
					contentdown: '查看更多',
					contentrefresh: '加载中',
					contentnomore: '没有更多内容了'
				},
				status: "more",
				params:{
					pageNo:1,
					pageSize:100,
					type:0,
					status: 0,
				},
				pages:0,
				messageList:[],
				show1: false,
				options: [{
				    icon: 'success',
				    style: {
				      backgroundColor: '#FFA726',
				      width: '80rpx',
				      height: '80rpx',
				      margin: '0 12rpx',
				      borderRadius: '100rpx'
				    }
				  },
				  {
				    icon: 'delete',
				    style: {
				      backgroundColor: '#E83A30',
				      width: '80rpx',
				      height: '80rpx',
				      margin: '0 12rpx',
				      borderRadius: '100rpx'
				    }
				  }
				],
				messageCount:{},
				titles:["通知","公告"]
			}
		},
		created() {
			this.onLoadShow()
		},
		methods: {
			parseTime,
			onLoadShow(){
				this.params.pageNo = 1
				this.params.type = 1
				this.getMessageNotice()
			},
			errorResponse(res){
				if(res.code != 200) {
					this.$tn.message.toast(res.message)
					return
				}
			},
			getMessageNotice(){
				this.messageList=[]
				this.$tn.message.loading("加载中")
				getMessageNotice(this.params).then(res =>{
					this.$tn.message.closeLoading()
					if(res.code != 0) {
						this.$tn.message.toast(res.msg)
						return
					}
					this.messageList = res.data.list
					this.pages = res.data.pages
					this.status = this.params.pageNo == this.pages || !this.pages ? "noMore" : "more"

				})
			},
			handleMessageNotice(type){
				if(this.params.type == type ){
					return
				}

				this.params.type = type;
				this.params.pageNo = 1
				this.getMessageNotice()
			},
			handlePage(val){
				if (this.status == "noMore") {
					return
				}
				this.$tn.message.loading('加载中')
				this.status = "loading";
				this.params.pageNo++;
				getMessageNotice(this.params).then(res => {
					this.$tn.message.closeLoading()
					this.messageList.push(...res.data.records)
					this.pages = res.data.pages
					this.status = this.params.pageNo == this.pages || !this.pages ? "noMore" : "more"
				})
			},
		  // 弹出模态框
		  showModal(event) {
			this.openModal()
		  },
		  // 打开模态框
		  openModal() {
			this.show1 = true
		  },
		}
	}
</script>
<style lang="scss" scoped>
.template-plan{
}
/* 胶囊*/
.tn-custom-nav-bar__back {
	width: 100%;
	height: 100%;
	position: relative;
	display: flex;
	justify-content: space-evenly;
	align-items: center;
	box-sizing: border-box;
	background-color: rgba(0, 0, 0, 0.15);
	border-radius: 1000rpx;
	border: 1rpx solid rgba(255, 255, 255, 0.5);
	color: #FFFFFF;
	font-size: 18px;

	.icon {
		display: block;
		flex: 1;
		margin: auto;
		text-align: center;
	}

	&:before {
		content: " ";
		width: 1rpx;
		height: 110%;
		position: absolute;
		top: 22.5%;
		left: 0;
		right: 0;
		margin: auto;
		transform: scale(0.5);
		transform-origin: 0 0;
		pointer-events: none;
		box-sizing: border-box;
		opacity: 0.7;
		background-color: #FFFFFF;
	}
}


.image-banner{
	display: flex;
	align-items: center;
	justify-content: center;
	// border: 1rpx solid red;
}
.image-banner image{
	width: 100%;
	height: 100%;
}
/* 轮播指示点 start*/
.indication{
	z-index: 9999;
	width: 100%;
	height: 36rpx;
	position: absolute;
	display:flex;
	flex-direction:row;
	align-items:center;
	justify-content:center;
}

.spot{
	background-color: #000;
	opacity: 0.4;
	width: 10rpx;
	height: 10rpx;
	border-radius: 20rpx;
	margin: 0 8rpx !important;
	right: -270rpx;
	top: -100rpx;
	position: relative;
}

.spot.active{
	opacity: 1;
	width: 10rpx;
	background-color: #000;
}

/* 计划内容 start*/
.tn-plan-content {
	&__item {
		display: inline-block;
		line-height: 45rpx;
		padding: 10rpx 30rpx;
		margin: 20rpx 20rpx 5rpx 0rpx;

		&--prefix {
			padding-right: 10rpx;
		}
	}
}
.tn-plan-content2 {
	&__item {
		line-height: 45rpx;
		padding: 15rpx 30rpx;
		margin: 30rpx 0rpx 10rpx 0rpx;

		&--prefix {
			padding-right: 10rpx;
		}
	}
}
/* 计划内容 end*/

/* 资讯主图 start*/
.image-article {
	border-radius: 8rpx;
	border: 1rpx solid #F8F7F8;
	width: 200rpx;
	height: 200rpx;
	position: relative;
}

.image-pic {
	background-size: cover;
	background-repeat: no-repeat;
	// background-attachment:fixed;
	background-position: top;
	border-radius: 10rpx;
}

.article-shadow {
	border-radius: 15rpx;
	box-shadow: 0rpx 0rpx 50rpx 0rpx rgba(0, 0, 0, 0.07);
}

/* 文字截取*/
.clamp-text-1 {
	-webkit-line-clamp: 1;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	text-overflow: ellipsis;
	overflow: hidden;
}

.clamp-text-2 {
	-webkit-line-clamp: 2;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	text-overflow: ellipsis;
	overflow: hidden;
}

/* 标签内容 start*/
.tn-tag-content {
	&__item {
		display: inline-block;
		line-height: 35rpx;
		padding: 5rpx 25rpx;

		&--prefix {
			padding-right: 10rpx;
		}
	}
}
</style>
<style lang="scss" scoped>
  /* 图标容器1 start */
  .icon1 {
    &__item {
      width: 30%;
      background-color: #FFFFFF;
      border-radius: 10rpx;
      padding: 30rpx;
      margin: 20rpx 10rpx;
      transform: scale(1);
      transition: transform 0.3s linear;
      transform-origin: center center;
      &--icon {
        width: 90rpx;
        height: 90rpx;
        font-size: 60rpx;
        border-radius: 50%;
        margin-bottom: 18rpx;
        position: relative;
        z-index: 1;

        &::after {
          content: " ";
          position: absolute;
          z-index: -1;
          width: 100%;
          height: 100%;
          left: 0;
          bottom: 0;
          border-radius: inherit;
          opacity: 1;
          transform: scale(1, 1);
          background-size: 100% 100%;
          background-image: url(https://resource.tuniaokj.com/images/cool_bg_image/icon_bg5.png);
        }
      }
    }
  }

</style>


